package com.swust.excel.write.morsheet;

import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelWriter;
import com.alibaba.excel.write.metadata.WriteSheet;
import com.swust.excel.write.onesheet.WriteOneBean;

import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

/**
 * @author: Chen Yixing
 * @since: 2023/11/16 16:41:53
 * @description:
 */
public class WriteMorMain {

    public static void main(String[] args) {
        // 表一写入
        ExcelWriter writer = EasyExcel.write("D:/data/morsheet.xlsx", WriteMorBean.class).build();
        WriteSheet sheet = EasyExcel.writerSheet(0, "基础信息").build();
        writer.write(listSheet(), sheet);

        // 表二写入
        WriteSheet sheet2 = EasyExcel.writerSheet(1, "详细信息").head(WriteMorBean.class).build();
        writer.write(listSheet(), sheet2);

        // 关闭流
        writer.finish();
    }

    private static List<WriteMorBean> listSheet() {
        List<WriteMorBean> list = new ArrayList<>();
        for (int i = 0; i < 6; i++) {
            list.add(new WriteMorBean("" + i, UUID.randomUUID().toString()));
        }
        return list;
    }

}
